package com.qf.fengmimall.order.until;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author 刘欣
 * @createTime 2023/2/17 13:46
 * @description 生成订单号
 */
public class OrderNumCreate {

    public static String randomOrderCode() {
        SimpleDateFormat dmDate = new SimpleDateFormat("yyyyMMddHHmmss");
        String randata = getRandom(6);
        Date date = new Date();
        String dateran = dmDate.format(date);
        String Xsode = "XS" + dateran + randata;
        if (Xsode.length() < 24) {
            Xsode = Xsode + 0;
        }
        return Xsode;
    }

    public static String getRandom(int len) {
        Random r = new Random();
        StringBuilder rs = new StringBuilder();
        for (int i = 0; i < len; i++) {
            rs.append(r.nextInt(10));
        }
        return rs.toString();
    }

}
